/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{
    /** Serialization capability enumeration */
    enum SERIALIZERCAPABILITY
    {
        CAN_EXPORT = 1,         /** Serializer can export */
        CAN_IMPORT = 2          /** Serializer can import */
    };

    /** Scene loading result enumeration */
    enum SCENEFILERESULT
    {
        SCF_OK = 1,             /** Scene was loaded successfully */
        SCF_CANCEL = 0,         /** Scene was not loaded */
        SCF_ERRUNKNOWN = -1,    /** Unknown error has occured during loading of the scene */
        SCF_ERRFILE = -2,       /** Invalid import file or parsing error on structure level */
        SCF_ERRPARSE = -3,      /** Parsing error has occured during scene loading */
        SCF_ERROGRE = -4        /** Ogre error has been raised during scene loading */
    };

    //! Base serializer class
    /*!  
        A class that is responsible for serialization/deserialization of scene file
    */
    class OgitorExport CBaseSerializer
    {
    public:
        /**
        * Constructor
        * @param typestring type name of the serializer
        * @param capability capabilities of the serializer (@see SERIALIZERCAPABILITY)
        */
        CBaseSerializer(Ogre::String typestring = "Base Serializer", unsigned int capability = 0) : m_TypeName(typestring), m_TypeID(0), m_Capability(capability) {};
        /**
        * Destructor
        */
        virtual ~CBaseSerializer() {};

        /**
        * Fetches type name of the serializer
        * @return type name of the serializer
        */
        inline Ogre::String GetTypeString() {return m_TypeName;};
        /**
        * Fetches type ID of the serializer
        * @return type ID of the serializer
        */
        inline unsigned int GetTypeID() {return m_TypeID;};
        /**
        * Sets type ID of the serializer
        * @param ID sets type ID the serializer
        */
        inline void         SetTypeID(unsigned int ID) {m_TypeID = ID;};
        /**
        * Tests if serializer object can export
        * @return true if serializer object can export, otherwise false
        */
        inline bool         CanExport() {return ((m_Capability & CAN_EXPORT) != 0);};
        /**
        * Tests if serializer object can import
        * @return true if serializer object can import, otherwise false
        */
        inline bool         CanImport() {return ((m_Capability & CAN_IMPORT) != 0);};

        /**
        * Tests if serializer object requires scene to be terminated before importing new scene
        * @return true if serializer object requires scene to be terminated before importing new scene, otherwise false
        */
        virtual bool RequiresTerminateScene() {return false;};
        /**
        * Exports scene data
        * @param SaveAs flag signifying that a "Save As" dialog is invoked to save scene file into different place
        * @return @see SCENEFILERESULT
        */
        virtual int  Export(bool SaveAs = false) {return false;};
        /**
        * Imports scene data
        * @param importfile file name of imported scene
        * @return @see SCENEFILERESULT
        */
        virtual int  Import(Ogre::String importfile = "") {return false;};

    protected:
        Ogre::String m_TypeName;            /** Serializer type name */
        unsigned int m_TypeID;              /** Serializer type ID */
        unsigned int m_Capability;          /** Serializer import/export/other capabilities */
    };
};
